home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-12 | 5.5 KB | 177 lines | [TEXT/MMCC] |
- /*********************************************************************
-
- Simple Sample.h
-
- This is the header file for the QuickDraw GX unaware sample,
- "Simple Sample."
-
- Additional info can be found in the related develop #19 article,
- "Adding QuickDraw GX Printing to QuickDraw Applications."
-
- Dave Hersey, Apple Developer Technical Support.
-
- ——————— Edit Trail ———————
-
- spawned: 1/22/94 - dmh
- cleaned up for 2nd draft of develop article: 3/10/94 - dmh
- cleaned up for final: 4/14/94 - dmh
- universalized: 8/24/94 - dmh
-
- *********************************************************************/
-
- //#include <stdio.h>
- #include <AppleEvents.h>
- #include <Desk.h>
- #include <Events.h>
- #include <Files.h>
- #include <Fonts.h>
- #include <GestaltEqu.h>
- #include <Memory.h>
- #include <Packages.h>
- #include <Printing.h>
- #include <Quickdraw.h>
- #include <Resources.h>
- #include <StandardFile.h>
- #include <ToolUtils.h>
- #include <Types.h>
- #include <Windows.h>
- #include <GXExceptions.h> // <-- Note that this does not use QuickDraw GX.
-
-
- #define kOSEvent app4Evt /* Event used by MultiFinder */
- #define kSuspendResumeMessage 1 /* High byte of suspend/resume event message */
- #define kResumeMask 1 /* Bit of message field for resume vs. suspend */
-
- #define r_About 128 /* Our app's "About…" alert ID. */
- #define r_BadConfig 130 /* Our app's "Bad configuration…" alert ID. */
- #define r_documentPict 128 /* Our PICT's resource ID. */
- #define r_documentBitmap 128 /* Our ICON's resource ID. */
-
- #define kMyDocCreator 'SSam' /* Our app's creator. */
- #define kMyDocType 'aDoc' /* Our document file type. */
- #define kMyPageCountType 'Pgs?' /* Our page count resource type. */
- #define kMyPageCountID 2000 /* Our page count resource ID. */
- #define kMyPrintRecType 'THPR' /* Our print record resource type. */
- #define kMyPrintRecID 1000 /* Our print record resource ID. */
-
- #define kDefaultTitle ((char *) "\pUntitled Document")
-
- // Various PicComments:
-
- #define PostScriptBegin 190
- #define PostScriptEnd 191
- #define PostScriptHandle 192
-
-
- /*
- MyDocumentRec - This structure contains information that we store
- about each document we open or create. We store a handle to one
- of these beasties in each window's refCon field. Note that the
- MyDocumentRec data type in this example is simplified to handle a
- maximum of 20 pages.
- */
-
- #define kMaxPages 20
-
- typedef struct MyDocumentRec {
- THPrint documentPrintHdl; // Print Record bound to this document.
- long numPages; // Number of pages in this document.
- long curPage; // The current page that we're looking at.
- FSSpec documentFSSpec; // The file specification for this document.
- Str31 documentTitle; // The title of this document (such
- // as "Untitled").
- WindowPtr documentWindow; // The window for this document.
- } MyDocumentRec, *MyDocumentPtr;
-
-
- // globals from main.c:
-
- extern short gAppResRefNum;
- extern Rect gWindowRect;
- extern Boolean gQuitAfterPrinting, gQuitting, gSystemSevenIsPresent;
- extern long gSleep;
-
- // Prototypes: //
-
- // main.c:
-
- void MyInitialize(void);
- void MyCheckConfig(void);
- void main(void);
-
- // events.c
-
- void MyEventLoop(void);
- void MyDoEvent(EventRecord *theEvent);
- void MyDoAEInstallation(void);
- pascal OSErr MyHandleOAPP(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal OSErr MyHandleQUIT(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal OSErr MyHandleODOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- pascal OSErr MyHandlePDOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
- OSErr MyCheckAEParams(AppleEvent *theAppleEvent);
-
- // file.c
-
- OSErr MyLoadDocument(MyDocumentPtr whichDocument);
- OSErr MyFSLoadDocument(MyDocumentPtr destDocument, FSSpec *docFSSpec, Boolean forPrinting);
- Boolean MyIsWindowAlreadyOpen(FSSpec *whichFSSpec);
- OSErr MySaveDocument(MyDocumentPtr myDocument, Boolean doingSaveAs);
- OSErr MySavePageCount(MyDocumentPtr whichDocument, short resRefNum);
- long MyLoadPageCount(short resRefNum);
- OSErr MySavePrintInfo(MyDocumentPtr whichDocument, short resRefNum);
- OSErr MyLoadPrintInfo(MyDocumentPtr whichDocument, short resRefNum);
-
- // menus & windows.c:
-
- OSErr MyCreateDocument(char *title, MyDocumentPtr *createdDocument);
- void MyDisposeDocument(MyDocumentPtr whichDocument);
- OSErr MyInsertPage(MyDocumentPtr whichDocument, long *whichPage);
- void MyDisposePage(MyDocumentPtr whichDocument, long whichPage);
- void MyUpdateWindow(WindowPtr whichWindow);
- void MyDrawContents(WindowPtr whichWindow);
- void MyDrawPicComments(void);
- void MySendPostScript(Str255 thePostScript);
- void MyAdjustMenus(void);
- void MyDoMenuCommand(long menuResult);
- MyDocumentPtr MyGetDocPtr(WindowPtr whichWindow);
-
- // printing.c:
-
- OSErr MyPrintDocument(MyDocumentPtr whichDocument);
- OSErr MyPrintLoop(MyDocumentPtr whichDocument);
- Boolean MyDoPageSetup(MyDocumentPtr whichDocument);
- void MyRepaginateDoc(MyDocumentPtr whichDocument);
-
-
- // resource & menu item equates:
-
- #define rMenuBar 128
- #define mApple 128
- #define iAbout 1
-
- #define mFile 129
- #define iNew 1
- #define iOpen 2
- #define iClose 3
- #define iSave 4
- #define iSaveAs 5
- #define iPageSetup 7
- #define iPrint 8
- #define iQuit 10
-
- #define mEdit 130
- #define iUndo 1
- #define iCut 3
- #define iCopy 4
- #define iPaste 5
- #define iClear 6
-
- #define mDocument 131
- #define iInsertPage 1
- #define iDeletePage 2
- #define iAheadPage 4
- #define iBackPage 5
-
-
-
-